<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <span id="num"></span>
    </div>
</body>
<!-- <script src="https://cn.vuejs.org/js/vue.js"></script> -->
<script>
    let data = {
        value:123,
        msg:"😊"
    }
    document.querySelector('#num').innerHTML = data.value;
    console.log(Object.keys(data));
    
    let $data = {}
    Object.keys(data).map(v=>{
        // Object.defineProperty() 方法会直接在一个对象上定义一个新属性，
        // 或者修改一个对象的现有属性，并返回此对象。
        Object.defineProperty($data,v,{
            get:function(){
                console.log("获取data中的",v,"值");
                return data[v];
            },
            set:function(){
                console.log("设置data中的新的值,",newValue,"旧的值是",data[v]);
                document.getElementById("num").innerHTML = newValue;
            }
        })
    })
    console.log($data);
</script>
</html>